package com.xiangban.rabbitMq;

import com.xiangban.dao.OrderMapper;
import com.xiangban.dao.RelationMapper;
import com.xiangban.model.dto.OrderDto;
import com.xiangban.util.CommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author ly
 * @date 2021/12/4 17:05
 */
@Component
@Slf4j
@RabbitListener(queues = "doctor_order_dead_queue")
public class CancelOrderReceiver {
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private RelationMapper relationMapper;


    @RabbitHandler
    public void handle(String orderId) {
        log.info("进入死信队列，已接收到参数："+orderId);
        //查询状态
        OrderDto  orderDto = new OrderDto();
        orderDto.setOrderNo(orderId);
        orderDto.setStatus(7);
        OrderDto statusByOrderNo = orderMapper.getStatusByOrderNo(orderDto);
        if (!CommonUtil.BizEmpty(statusByOrderNo)){
            Integer status = statusByOrderNo.getStatus();
            if (status==1){
                orderMapper.updateStatusByorderNo(orderDto);//修改超市状态

            }
        }

    }
}
